package leetcode.hash;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;

/**
 * https://leetcode-cn.com/problems/repeated-dna-sequences/
 *
 * @author mazouri
 * @create 2021-10-08 12:21
 */
public class _187_findRepeatedDnaSequences {
    public List<String> findRepeatedDnaSequences(String s) {
        HashSet<String> set = new HashSet<>();
        HashSet<String> resSet = new HashSet<>();

        for (int i = 0; i <= s.length() - 10; i++) {
            String subStr = s.substring(i, i + 10);
            if (set.contains(subStr)) {
                resSet.add(subStr);
            } else {
                set.add(subStr);
            }
        }
        return new ArrayList<>(resSet);
    }

    public static void main(String[] args) {
        System.out.println(new _187_findRepeatedDnaSequences()
                .findRepeatedDnaSequences("AAAAAAAAAAA"));

        System.out.println("aaaaaaaaaab".substring(0, 10));
    }
}
